package algorithms;

public class SerialEnumSort implements  SortStrategy{
    private int[] data;
    private int[] ret;

    public SerialEnumSort() {
        ;
    }

    public int[] sort(int[] data) {
        // 
        this.data = data.clone();
        this.ret = new int[this.data.length];

        for (int i=0; i<this.data.length; i++) {
            int place = 0;
            for (int j=0; j<this.data.length; j++) {
                if (this.data[j] < this.data[i]) place ++;
                if (this.data[j] == this.data[i])
                    place += (j>i)?1:0;
            }
            this.ret[place] = this.data[i];
        }
        return this.ret;
    }
}
